package 作业2;

// public class NarcissisticNumbers {

//   public static void main(String[] args) {
//     for (int num = 100; num <= 999; num++) {
//       int originalNumber = num;
//       int sum = 0;

//       while (num > 0) {
//         int digit = num % 10;
//         sum += Math.pow(digit, 3);
//         num /= 10;
//       }

//       if (sum == originalNumber) {
//         System.out.println(originalNumber + "是一个水仙花数");
//       }
//     }
//   }
// }


public class NarcissisticNumbers {

  public static void main(String[] args) {
    for (int num = 100; num <= 999; num++) {
      int originalNumber = num;
      int sum = 0;

      while (originalNumber > 0) {
        int digit = originalNumber % 10;
        sum += Math.pow(digit, 3);
        originalNumber /= 10;
      }

      if (sum == num) {
        System.out.println(num + "是一个水仙花数");
      }
    }
  }
}
